<template>
  <biz-project-form
    v-if="formConfig.formKey"
    :form-config="formConfig"
    @submit="submitForm"
    class="t-form-theme-wrap"
  />
</template>

<script>
import BizProjectForm from "@/views/formgen/components/BizProjectForm/index.vue";
import { getSettingRequest } from "@/api/project/setting";
import { isWxEnv } from "@/views/form/write/hooks/wx";

export default {
  components: {
    BizProjectForm
  },
  data() {
    return {
      formConfig: {
        setting: {},
        formKey: "",
        preview: true,
        showBtns: true
      }
    };
  },
  created() {
    this.formConfig.formKey = this.$route.query.key;
    if (!isWxEnv()) {
      getSettingRequest(this.formConfig.formKey).then(res => {
        if (res.data) {
          this.formConfig.setting = res.data;
        }
      });
    }
  },
  methods: {
    submitForm() {
      this.msgError("预览模式下不支持提交数据哦~");
    }
  }
};
</script>
